package hzk.codex2016.list;

public class Lists {
	
	/**
	 * build a singly linked list
	 * @param vals
	 * @return
	 */
	public static ListNode sll(int... vals) {
		if (vals == null)
			return null;
		return ListNode.asList(vals, vals.length);
	}
	
	public static ListNode copyOf(ListNode src){
		if (src==null) return null;
		ListNode head=new ListNode(src.val),p=head;
		while ((src=src.next)!=null){
			p=p.next=new ListNode(src.val);			
		}
		return head;
	}

	
	public static void main(String[] args){
		System.out.println(copyOf(sll(1,2,3,4,5,6)));
	}

}
